/*jshint          browser : true,  continue  :  true
  devel  : true,  indent  : 2,     maxerr    :  50
  newcap : true,  nomen   : true   plus      :  true
  regexp : true,  sloppy  : true   vars      :  false
  white  : true
*/

'use strict';

var gulp     = require('gulp'),
    jshint   = require('gulp-jshint'),
    uglify   = require('gulp-uglify'),
    stylish  = require('jshint-stylish'),
    del      = require('del'),
    concat   = require('gulp-concat'),
    plumber  = require('gulp-plumber'),
    bower    = require('gulp-bower'),
    react    = require('gulp-react'),
    eslint   = require('gulp-eslint'),
    // reactify = require('reactify'),
    // browserify = require('browserify'),
    // source   = require('vinyl-source-stream'),
    // buffer = require('vinyl-buffer'),
    sourcemaps = require('gulp-sourcemaps');

var base = {
    distPath: 'dist/',
    distJs: 'app.js',
    sourceJsPath: 'www/controller/*.js',
    distIndexHtmlPath: 'www/index.html'
};

var paths = [base.sourceJsPath];

gulp.task('package', ['clean', 'concat']);

gulp.task('default', ['concat']);

gulp.task('eshint', function(){
  gulp.src(paths)
      .pipe(eslint())
      .pipe(eslint.format());
});

gulp.task("clean", function(){
  del([base.distPath]);
});

gulp.task('moveIndexHtml', function(){
  gulp.src(base.distIndexHtmlPath)
      .pipe(plumber())
      .pipe(gulp.dest(base.distPath));
})
gulp.task("concat", ['moveIndexHtml'],function(){ 
  gulp.src(paths)
      .pipe(plumber())
      .pipe(concat(base.distJs))
      .pipe(gulp.dest(base.distPath));
});

gulp.task('watch', function(){
  var pathsIncludeIndexHtml = paths;
  // pathsIncludeIndexHtml.push(base.distIndexHtmlPath);
  gulp.watch(pathsIncludeIndexHtml, ['package']);
});













